const Router = require('../lib/router');
const router = new Router();
/**
 * @swagger
 * /op/info/{id}:
 *   get:
 *     tags: [default]
 *     summary: Find pet by ID
 *     description: Returns a single pet
 *     operationId: getPetById
 *     parameters:
 *       - name: id
 *         in: path
 *         description: id
 *         required: true
 *         type: string
 *     responses:
 *      '200':
 *        description: 接口请求成功
 */
router.get('/op/info/:id', async (ctx) => {
  const { params } = ctx;
  if (params.id && +params.id > 10) {
    // ctx.throwError("id错误")
    throw new Error('id错误');
  }
  return 'op:' + params.id;
});
/**
 * @swagger
 * /index:
 *   get:
 *     summary: Returns a list of users.
 */
router.get('/index', async (ctx) => {
  ctx.type = 'html';
  return process.env.NODE_ENV;
});
module.exports = router;
